package com.yonyou.gmmc.service.wechatpush.event.service;

import java.util.Date;

import org.marketing.common.event.BizEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.google.common.util.concurrent.ListeningExecutorService;
import com.yonyou.gmmc.service.wechatpush.event.handler.AbstractEventHandle;
import com.yonyou.gmmc.service.wechatpush.event.handler.EventHandleFactory;
import com.yonyou.gmmc.service.wechatpush.event.handler.HandleResult;

import tk.mybatis.mapper.entity.Example;

@Service
@Transactional
public class WechatEventService {

	private static Logger logger = LoggerFactory.getLogger(WechatEventService.class);

    @Autowired
    private ListeningExecutorService executorService;

	/**
	 * 处理积分的时间
	 * 
	 * @param event
	 * @return 返回是否处理完毕，true完毕，false可以重试
	 */
	public HandleResult HandleWechatEvent(BizEvent event) {
		// 创建处理的对象
		AbstractEventHandle handle = EventHandleFactory.createHandle(event);		
		if(handle==null){
			HandleResult result=new HandleResult();
			result.setHandle(true);
			result.setMessage("不处理该消息");
			return result;
		}
		handle.executorService=executorService;
		// 创建处理的对象
		HandleResult result = handle.handleing(event);

		return result;
	}

}
